package com.zlll.winner.common;

import com.zlll.winner.business.model.sysUser.SysUser;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    @Autowired(required = false)
    protected HttpServletRequest request;
    @Autowired(required = false)
    protected HttpServletResponse response;
    @Autowired(required = false)
    protected HttpSession session;

    /**
     * 获取用户信息
     * @return
     */
    public SysUser getUser(){
        return (SysUser) this.session.getAttribute("user");
    }

    /**
     * 获取用户id
     * @return
     */
    public Long getUserId(){
        return getUser().getId();
    }
}
